<template>
  <div style="min-height: 100vh;background:#f5f5f5;">
    <div v-if="list">
      <myAddress :list="list" :type="type"></myAddress>
    </div>
    <div v-else>
      <div class="noAddress">
        <img src="/static/img/address1.png" alt="">
        <p>你还没有添加收货地址哦~</p>
      </div>
    </div>
    <div class="addAddress" @click="addAddress">
      <p>新增地址</p>
    </div>
  </div>
</template>

<script>
  import request from "@/actions/request.js"
  import myAddress from '@/components/addressList/myAddress'
  export default {
    name: "myAddress",
    components: {
      myAddress
    },
    data() {
      return {
        data:{},
        chosenAddressId: '1',
        list: [],
        type:''
      }
    },
    watch:{

    },
    onLoad(){

    },
    methods:{

      addAddress(){
        wx.navigateTo({
          url: '../addAddress/main'
        })
      },
      onEdit(item, index) {
        wx.navigateTo({
          path: '/editAddress?addressId='+item.id+'&name='+item.name+'&tel='+item.tel+'&area='+item.area+'&address='+item.smallAddress+'&is_default='+item.is_default+'&first_id='+item.first_id+'&second_id='+item.second_id+'&third_id='+item.third_id
        });
      },
      onselect(item,index){
        request.setDefaultAddress(this,item.id,item)
      }
    },
    onShow(){
      this.list=[];
      request.addressList('api/user/addressList','post',{},{},true,this);
    },
    mounted() {
      this.type = this.$root.$mp.query.type;
    },
  }
</script>

<style scoped lang="scss">
  .addAddress{
    width: 100vw;
    height: 14vw;
    background:#ff4444;
    position: fixed;
    bottom: 0;
    p{
      color: #fff;
      font-size: 17px;
      text-align: center;
      line-height: 14vw;
    }
  }
  .myBalance{
    text-align: center;
    color: #ffffff;
    font-size: 13px;
    padding-top: 45px;
    p{
      font-size: 20px;
    }
  }
  .fanli{
    display: flex;
    justify-content: space-between;
    padding: 14px 0;
    >div{
      width:50%;
      text-align: center;
      font-size: 13px;
      color: #666666;
      font-size: 13px;

    }
    .allBlance,.monthBlance{
      color:#333333;
      font-size: 15px;
    }
  }
  .noAddress{
    text-align:center;
    padding-top: 120px;
    color: #333333;
    font-size: 14px;
    img{
      width: 158px;
      height: 110px;
      margin-bottom: 20px;
    }
  }

</style>
